import 'package:flutter/material.dart';
import 'package:qr_code_app/common/service/app_data.dart';
import 'package:qr_code_app/common/service/event_extension.dart';
import 'package:qr_code_app/module/login/request/login_request.dart';
import 'package:qr_code_app/module/user/bloc/user_bloc.dart';
import 'package:todo_flutter/todo_flutter.dart';

part 'login_event.dart';

part 'login_state.dart';

class LoginBloc extends BaseBloc<LoginEvent, LoginState> {
  final TextEditingController codeController = TextEditingController();
  final TextEditingController phoneController = TextEditingController();

  // Next是否高亮
  final DataChangeBloc<bool> hasNextBtnHighlightBloc = DataChangeBloc(false);

  LoginBloc() : super(LoginInitState());

  void login() {
    add(PhoneLoginEvent(phoneController.text, codeController.text));
  }

  @override
  Future<void> close() async {
    codeController.dispose();
    phoneController.dispose();
    hasNextBtnHighlightBloc.close();
    await super.close();
  }
}
